<%@ include file="/common/taglibs.jsp"%>
<%@ page pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>
角色管理
</title>

<script src="<c:url value='/scripts/common.js'/>"></script>
<link href="<c:url value="/styles/css.css"/>" rel="stylesheet" type="text/css" />
<link href="./styles/layout.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F4F4F4;
}
-->
</style>
<script>


	function formSubmit2(theform,text){
	if(checkMSISDN()){
	document.forms[0].actionflag.value=text;
theform.submit();
}
//parent.rightdownFrame.location.reload();  
	}
	
	function formSubmit3(theform,text){

/*  if(element.value.length<1){
       alert("请先选择要修改的记录！");
       return false;
   }*/
	//if(checkMSISDN()){
	document.forms[0].actionflag.value=text;
theform.submit();
//}
	}

	function delWord(){
		if(!checkIds()){
			alert("请在下面列表中选择要删除的黑名单！");
		}else{
			document.forms[0].actionflag.value="delete";
			document.forms[0].submit();
		}
	}
	
	function checkIds(){
		var elements = document.forms[0].document.getElementsByName("ids");
		var j = 0;
		for(i=0;i<elements.length;i++){
			e = elements[i];
			if(e.checked == true){
				j++;
			}
		}
		if(j>0)
			return true;
		else 
			return false;
	}
	
	
function checkMSISDN(){
//   var element =document.getElementById("msisdn");
//   if(element.value.length<1){
//       alert("手机号不能为空！");
//       return false;
//   }
 
//   var exp=new RegExp("^13\\d{9}$");
//   if(!exp.test(element.value)){
//      alert("手机号码格式不正确！");
//   return false;
//   }
   
   return true;
}

function formSubmitseByID(theform,text,idtxt){
	document.forms[0].idtxt.value=idtxt;
	document.forms[0].actionflag.value=text;
theform.submit(); 
	}
	
	function selectall(){
  var isChecked = document.forms[0].chkall.checked;
  if(document.forms[0].length == null){
    document.forms[0].elements[i].checked = isChecked;
    return;
  }
  else{
    for(i=0;i<document.forms[0].length;i++){       
      document.forms[0].elements[i].checked=isChecked;
    }
	return;
  }
} 
</script>
</head>


<body leftmargin="0" topmargin="0">
<bean:define id="roleFuncForm" name="roleFuncForm"
	type="com.sasis.webapp.form.RoleFuncForm" />
	<html:form action="roleFuncAction.html?method=getAll">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
	          <tr>
	            <td class="home-content-title" ><img src="images/passenger.gif" width="21" height="22" align="absmiddle"/><fmt:message key="menu.manager.title.roleInfo" />
	           </td>
	          </tr>
            	<tr>
              	<td height="25" class="home-table-tool-content02">
        		  		<input type="button" class="home-table-inputbox" value=<fmt:message key="button.add" /> onclick="MM_openBrWindow('./roleFuncAction.html?method=add','newRole','width=500,height=270')" 
        		  		 
        		  		<p:notAllow pid="6331"> 
        		  			disabled
        		  		</p:notAllow>
        		  		/>
        			
                		<input type="button" class="home-table-inputbox" value=<fmt:message key="common.button.delete" /> onclick="javascript:submitData('deleteRol')" 
                		<p:notAllow pid="6333"> 
        		  			disabled
        		  		</p:notAllow>
                		/>
        			</td>
        			</tr>
        			<tr>
					<td height="30" class="home-search-space">
						角色：&nbsp;
						<html:text property="urName" styleId="urName"
							styleClass="home-table-inputbox" size="15" />
						&nbsp;&nbsp;&nbsp;&nbsp; 描述：&nbsp;
						<html:text property="urDescription" styleId="urDescription"
							styleClass="home-table-inputbox" size="15" />&nbsp;&nbsp;&nbsp;&nbsp;
						<input name="Submit2" type="button" class="home-inputBtn" value="查询" onclick="javascript:Search();"/> 
					    
					</td>
				</tr>
    			  <tr> 
                       <td class="home-table-topline"> 
                       </td>
                   </tr>
		          			<tr>
		          			 <td class="home-table-leftline"><table width="100%" border="0" cellspacing="0" cellpadding="0">
		          			 <tr>
		          		      <td class="home-table-tool-content02 "><sasis:page items="${refInfoList}"/></td>
		          		      </tr>
		          		      
		          		      </table>
		    
							</tr>
   <tr> 
    <td valign="top"> <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
      
       
        <tr> 
          <td class="home-table-leftline"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td >&nbsp;</td>
              </tr>
              <tr> 
                <td align="center" valign="top" class="home-edittable-space">	
		<table width="100%" border="0" cellpadding="2" cellspacing="0" class="list_bordercolor">
                   
                    <tr> 
                      <td width="6%" class="home-list-title"><div align="center"> 
                          <input type='checkbox' name='selectall' 
				            		onClick='checkAll(this.checked);'/>
                        </div></td>
                      <td width="30%" class="home-list-title"><fmt:message key="user.common.role.name"/></td>
                      <td width="24%" class="home-list-title"><fmt:message key="user.common.role.desc"/></td>
                      <p:allow pid="6332"> 
                      <td width="20%" class="home-list-title"><fmt:message key="common.button.update" /></td>
                      </p:allow>
                    </tr>
                     <c:forEach var="results" items="${refInfoList}" varStatus="status" >
                   	<tr>
		                    		<td class="home-list-content" height="26" align="center"><input type="checkbox" name="checkBoxId"  value='<c:out value="${results.urID}"/>'/></td>
		                    		<td class="home-list-content"><c:out value="${results.urName}"/>&nbsp;</td>
		                    		<td class="home-list-content" ><c:out value="${results.urDescription}"/>&nbsp;</td>
		                    	<p:allow pid="6332"> 	
		                    		<td class="home-list-content" align="center"><img src="./images/edit.gif" width="14" height="14" style="cursor:hand" 
											alt="<fmt:message key="common.button.update" />"
										onclick="javascript:editData('selectOne',<c:out value="${status.count-1}"/>)"
										/></td>
								</p:allow>	
									
		                    	</tr></c:forEach>	                </table>
                  
                </td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td height="12"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td class="home-table-bottom-left">&nbsp;</td>
                <td class="home-table-bottom-bg">&nbsp;</td>
                <td class="home-table-bottom-right">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="10">&nbsp;</td>
  </tr>
</table>

<input type="hidden" name="method" vaule=""/>	 
<input type="hidden" name="aryId"> 
<input type="hidden" name="message" value="<fmt:message key="errors.func.select"/>">
<input type="hidden" name="view">
</html:form>
</body>

<script>	

 function submitData(method){
		//var pageIndex=getPageIndex(url,"pageIndex");
		var chk = document.forms[0].checkBoxId;
		var len = chk.length;
		var ary = new Array();
	    //alert(len);
//		document.forms[0].method.value=method;
		if(len>0){
		
		for(var i=0;i<len;i++){
			if(chk[i].checked){
				ary.push(chk[i].value);
			}
		}
		var aryAy = ary; 
		if(aryAy!=0){
		if(confirm("确定要删除该记录吗?")){
		document.forms[0].aryId.value = aryAy;
		//alert("len>0 and checked submit"+aryAy);
		document.forms[0].action="./roleFuncAction.html?method="+method;
		document.forms[0].submit();
		
		//return;
		  } }
		}else{
		//alert("len<=0 one submit");
		if(chk.checked){
		if(confirm("确定要删除该记录吗?")){
		document.forms[0].aryId.value = chk.value;
		document.forms[0].action="./roleFuncAction.html?method="+method;//+"&pageIndex="+pageIndex;
		document.forms[0].submit();
		return;
		}}
	}   //alert("ary"+ary.length);
	    if(ary.length==0)
		{alert(document.forms[0].message.value);}
		
		
	}
	
function newSubmit(method){ 
	    //document.forms[0].method.value=method;
	    document.forms[0].action="./roleFuncAction.html?method="+method;
	    document.forms[0].submit();
     }
     
     function viewSubmit(method,indx){ 
 
        document.forms[0].view.value = "view";
	    //alert(document.forms[0].view.value);
//	    alert(indx)
	    var chk = document.forms[0].checkBoxId;
	       
	    if(chk.length>1){
	           
	    	document.forms[0].aryId.value = chk[indx].value
	    }else document.forms[0].aryId.value = chk.value
	   // document.forms[0].method.value=method;
	   document.forms[0].action="./roleFuncAction.html?method="+method;
     	document.forms[0].submit();
//	    submitData(method,indx)
     }
     
       function editData(method,indx){  
    
	    var chk = document.forms[0].checkBoxId;
	    if(chk.length>1){
	    	document.forms[0].aryId.value = chk[indx].value
	    }else document.forms[0].aryId.value = chk.value
	    //document.forms[0].method.value=method;
	    var aryId = document.forms[0].aryId.value;
     	//document.forms[0].submit(); 
     	
     	window.location='./roleFuncAction.html?aryId='+aryId+'&method='+method;
//		MM_openBrWindow('./roleFuncAction.html?aryId='+aryId+'&method='+method,'','width=500,height=270');
     }
     
function checkAll(status){
               //alert(status);
               for (var i=0;i < document.forms[0].elements.length; i++){
				var e = document.forms[0].elements[i];
				//alert(e.name);
				if (e.name=="checkBoxId")
					document.forms[0].elements[i].checked=status;
			}
			
		}
		
		
 
 
function shSearch(eltName){
	 
	var elt = document.getElementById(eltName);

	if(elt.style.display=="none"){ 
		elt.style.display = "";
	}else elt.style.display = "none";

}
function Search(){
    //alert("come search");
    //将需要验证的ID传入数组
	var propertyArray = new Array();
	propertyArray.push("urName");
	propertyArray.push("urDescription");
	
	//alert(propertyArray.length)
	//把验证数组传入验证特殊字符函数
	var result=checkSpecialInput(propertyArray);
	//alert("result="+result);
	if(result==true||result==null){
	     //alert(result);
	    roleFuncForm.action="./roleFuncAction.html?method=getAll";
	    roleFuncForm.submit();
	     
	}else{
	    alert(result);
	}
}



//删除失败信息
var msg = '<c:out value="${message}"/>'; 
if('delfailure' == msg) alert("删除失败，可能有记录关联!");

</script>

</html>
